﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace StreamingServer
{
    public partial class frm_ServerDll : Form
    {
        PSERVER_VIDEOINFO pserver_videoinf;
        int sccess = 0;//服务器启动标志

        public frm_ServerDll()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (sccess != 1)
            {
                if (HikServerDLL.MP4_ServerStart(ref pserver_videoinf) != 0)
                {
                    //MessageBox.Show("启动成功");
                    //btnStart.Enabled = false;
                    button1.Enabled = false;
                    sccess = 1;
                }
            }
        }

        private void frm_ServerDll_Load(object sender, EventArgs e)
        {
            ////初始化
            //HikServerDLL中无初始化项
            //启动服务
            if (HikServerDLL.MP4_ServerStart(ref pserver_videoinf) != 0)
            {
                sccess = 1;
                //btnStart.Enabled = false;
                button1.Enabled = false;
            }

            //获取时间信息
            this.timer1.Start();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (HikServerDLL.MP4_ServerStop() == true)
            {
                //btnStart.Enabled = true;
                button1.Enabled = true;
                sccess = 0;
            }
        }

        private void button5_Click(object sender, EventArgs e)
        {
            if (sccess != 1)
            {
                Application.Exit();
            }
            else
            {
                MessageBox.Show("请先停止服务，才能退出");
            }
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            DateTime dt = DateTime.Now;
            label1.Text = dt.ToLongTimeString();
            label2.Text = dt.ToShortDateString();
        }
    }
}
